﻿using Dashboard.ViewModel;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;

namespace Dashboard.View
{
    /// <summary>
    /// LoginView.xaml 的交互逻辑
    /// </summary>
    public partial class LoginView : Window
    {
        public LoginView()
        {
            InitializeComponent();

            /// 关联本窗体的数据上下文（这样的话，本窗体绑定的命令才会委托给该ViewModel去执行）
            this.DataContext = new LoginViewModel();
        }
        /// <summary>
        /// 底部三种登录方式点击时触发
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void TextBlock_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            TextBlock textBlock = (TextBlock)sender;
            //textBlock.Foreground = new SolidColorBrush((Color)System.Windows.Media.ColorConverter.ConvertFromString("#2866FF"));
            //SolidColorBrush solidColorBrush = new SolidColorBrush((Color)System.Windows.Media.ColorConverter.ConvertFromString("#CCCCCC"));
            switch (textBlock.Name)
            {
                case "qq":
                    LogoImageBorder.Margin = new Thickness(7);
                    LogoImage.ImageSource = new BitmapImage(new Uri("../../Assets/images/icons_qq_64px.png", UriKind.Relative));
                    //wechat.Foreground = solidColorBrush;
                    //weibo.Foreground = solidColorBrush;
                    break;
                case "wechat":
                    LogoImageBorder.Margin = new Thickness(12);
                    LogoImage.ImageSource = new BitmapImage(new Uri("../../Assets/images/icons_wechat_64px.png", UriKind.Relative));
                    //qq.Foreground = solidColorBrush;
                    //weibo.Foreground = solidColorBrush;
                    break;
                case "weibo":
                    LogoImageBorder.Margin = new Thickness(11);
                    LogoImage.ImageSource = new BitmapImage(new Uri("../../Assets/images/icons_weibo_64px.png", UriKind.Relative));
                    //wechat.Foreground = solidColorBrush;
                    //qq.Foreground = solidColorBrush;
                    break;
            }
        }
        /// <summary>
        /// 鼠标点击顶部区域时触发：
        /// 拖动窗口
        /// 
        /// 注意：本事件点击即可触发，但是点击不一定会持续按住拖动，所以内部首先要判定触发点击事件后，鼠标左键是否还是处于按下状态
        /// </summary>
        /// <param name="sender">顶部区域的Border</param>
        /// <param name="e"></param>
        private void Border_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            /// 若：鼠标左键当前处于按下状态
            if(e.LeftButton == MouseButtonState.Pressed)
            {
                /// 设置窗口移动
                this.DragMove();
            }
        }
    }
}
